package thread.test_1;

public class Test10 {
    public static void main(String[] args) {
        Ticket ticket = new Ticket();
        new Thread(ticket,"窗口1").start();
        new Thread(ticket,"窗口2").start();
        new Thread(ticket,"窗口3").start();
    }
}
class Ticket implements Runnable {
    private int ticket = 100;
    @Override
    public void run() {
        while (true) {

            if (ticket <= 0){
                break;
            } else {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(Thread.currentThread().getName() + "正在卖第" + ticket-- + "张票");
            }
        }
    }
}
